package com.gopay.bis.cmbc.ebank.impl;

import com.gopay.bis.cmbc.ebank.operation.CmbcB2bQueryCerthelper;
import com.gopay.common.domain.bank.BaseMessage;
import com.gopay.common.domain.bank.cmbc.ebank.CmbcMessage;
import com.gopay.common.exception.GopayException;
import com.gopay.remote.bank.ICertHelper;
import com.gopay.remote.bank.businesses.BankService;

public class CmbcB2bBankServiceImpl implements BankService {

	/** B2B交易签名验签实现类 */
	private ICertHelper cmbcB2bCerthelper;
	
	private CmbcB2bQueryCerthelper cmbcB2bQueryCerthelper;
	/**
	 * CMBC签名处理
	 * @throws GopayException 
	 */
	public String sign(BaseMessage message) throws GopayException {
		CmbcMessage cmbcMessage = (CmbcMessage) message;
		String signMsg = "";
	    signMsg = (String) cmbcB2bCerthelper.sign(cmbcMessage);
		return signMsg;
	}

	/**
	 * CMBC验签处理
	 * 
	 * @throws GopayException
	 */
	public Object verify(BaseMessage msg) throws GopayException {
		CmbcMessage cmbcMessage = (CmbcMessage) msg;
		String verifyResult = (String) cmbcB2bCerthelper.verify(cmbcMessage);
		
		return verifyResult;
	}

	/**
	 * CMBC订单查询处理
	 * @throws GopayException 
	 */
	public Object query(Object obj) throws GopayException {
		CmbcMessage retMessage = new CmbcMessage();
		retMessage = (CmbcMessage) cmbcB2bQueryCerthelper.getB2bOrder((BaseMessage) obj);
		return retMessage;
	}

	public void setCmbcB2bCerthelper(ICertHelper cmbcB2bCerthelper) {
		this.cmbcB2bCerthelper = cmbcB2bCerthelper;
	}

	public void setCmbcB2bQueryCerthelper(
			CmbcB2bQueryCerthelper cmbcB2bQueryCerthelper) {
		this.cmbcB2bQueryCerthelper = cmbcB2bQueryCerthelper;
	}

	@Override
	public Object dayend(Object obj) throws GopayException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Object refund(Object obj) throws GopayException {
		// TODO Auto-generated method stub
		return null;
	}

}
